/*
 * @lc app=leetcode.cn id=1742 lang=javascript
 *
 * [1742] 盒子中小球的最大数量
 */

// @lc code=start
/**
 * @param {number} lowLimit
 * @param {number} highLimit
 * @return {number}
 */
var countBalls = function (lowLimit, highLimit) {
  const map = {};
  let max = 0;
  for (let i = lowLimit; i <= highLimit; i++) {
    let key = `${i}`.split('').reduce((p, c) => p + (+c), 0);
    map[key] = map[key] ? map[key]+1 : 1;
    max = Math.max(max, map[key]);
  }
  return max;
};
// @lc code=end

